// 草图 - 样条曲线
import { BaseCommand, CommandHint, CommandHintStatus } from '@amcax/base';
import { useEffect, useRef } from 'react';
import CmdInteractor from './CmdInteractor';
import { LineCommandProps } from './types';

function LineCommand({ onClose }: LineCommandProps) {
  const cmdRef = useRef<CmdInteractor>(null);
  useEffect(() => {
    cmdRef.current = new CmdInteractor();
    cmdRef.current.addExit(onClose);
    return () => {
      cmdRef.current?.destroy();
      cmdRef.current = null;
    };
  }, []);
  return (
    <CommandHint
      status={CommandHintStatus.INFO}
      content={''}
    />
  );
}

export const cmdSpline: BaseCommand = {
  id: 'CmdSpline',
  label: 'command.spline',
  icon: 'commands/sketch/spline',
  group: 'sketch',
  create: (label: string, onClose: () => void) => (
    <LineCommand
      title={''}
      onClose={onClose}
    />
  ),
};
